package com.robert.mvp.utils;

import java.lang.reflect.ParameterizedType;

/**
 * Des:该类则用于反射获取指定泛型
 *
 * @Author: cpf
 * @date: ${date} ${hour} ${minute}
 * @email: 2227039052@qq.com
 */
public class ReflectUtil {
    public static <T> T getT(Object o, int i) {
        try {
            return ((Class<T>) ((ParameterizedType)
                    (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
